package com.house.controller;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.house.pojo.Houselist;
import com.house.service.ListService;

@Controller
public class ListController {
	@Autowired
	private ListService listService;
	
	@RequestMapping("/list/{listId}")
	@ResponseBody
	public Houselist getListById(@PathVariable int listId){
		
		Houselist houselist = listService.getListById(listId);
		return houselist;
	}
	
	@RequestMapping("/findall")
	public String findAllUser(HttpServletRequest request){
		Houselist test = listService.getListById(1);
		request.setAttribute("testlist", test);
		return "indextest";
	}
	@RequestMapping("/save")
	@ResponseBody
	public String add(Houselist test){
		System.out.print(test.getHousekind());
		listService.add(test);
		return "success";
	}
	
}
